ID = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', ]
style = ['吃饭支出', '工资输入', '服装支出', '吃饭支出', '股票收入',
         '股票收入', '工资收入', '礼金支出', '其他支出', '交通支出',
         '吃饭支出', '工资收入', '交通支出', '工资收入', ]
account = ['交通银行', '现金', '现金', '现金', '工商银行',
           '工商银行', '交通银行', '现金', '现金', '交通银行',
           '工商银行', '现金', '现金', '现金', ]
money = ['247.0', '12345.0', '1998.0', '325.0', '8000.0', '5000.0', '5000.0', '5000.0',
         '1560.0', '2300.0', '1000.0', '1000.0', '2000.0', '5000.0', ]
time = ['2016-03-02', '2016-03-15', '2016-04-02', '2016-06-18', '2016-10-28',
        '2016-10-28', '2016-10-28', '2016-10-28', '2016-10-29', '2016-18-29',
        '2016-10-29', '2016-10-30', '2016-10-30', '2816-10-30', ]
instructions = ['家庭聚餐', '开工资了', '买衣服', '朋友聚餐', '股票大涨', '股票又大涨',
                '又开工资了',  '朋友结婚', '丢钱了', '油价还在涨啊', '又吃饭', '开资',
                '机票好贵', '又开资', ]

administrator = ['admini', 'lisi', ]
password = ['123456', '123456', ]


def exit_system():
    print("退出登录成功!")


def check_account():
    def c(styles):
        longs = len(ID)
        xx = 1
        while xx <= longs:
            print(styles[xx-1])
            xx += 1
        gg = input("请输入要查信息：")
        hh = 0
        nn = 0
        for mm in styles[0:longs]:
            if gg == mm:
                print(ID[hh], style[hh], account[hh], money[hh], time[hh],
                      instructions[hh], )
                nn += 1
            hh += 1
        if nn == 0:
            print("无该信息。")
    while True:
        print("1.查询全部  2.按条件查询")
        s = input("输入选择：")
        if s == "1":
            long = len(ID)
            x = 1
            while x <= long:
                print('%-5s\t%-5s\t%-5s\t%-5s\t%-5s\t%-5s\t' % (ID[x-1],  style[x-1], account[x-1], money[x-1],
                      time[x-1], instructions[x-1]))
                x += 1
        elif s == "2":
            while True:
                print("1.ID  2.类别  3.账户  4.金额  5.时间  6.说明")
                ss = input("输入选择：")
                if ss == "1":
                    c(ID)
                    break
                elif ss == "2":
                    c(style)
                    break
                elif ss == "3":
                    c(account)
                    break
                elif ss == "4":
                    c(money)
                    break
                elif ss == "5":
                    c(time)
                    break
                elif ss == "6":
                    c(instructions)
                    break
                else:
                    print("输入错误请重新输入！")
        else:
            print("输入错误请重新输入！")
        break


def del_account():
    ids = int(input("请输入ID:"))
    del ID[ids-1]
    del style[ids-1]
    del account[ids-1]
    del money[ids-1]
    del time[ids-1]
    del instructions[ids-1]
    long = len(ID)
    while ids-1 < long:
        ID[ids-1] = ids
        ids += 1
    print("删除账务成功!")


def edit_account():
    while True:
        print("1.类别  2.账户  3.金额  4.时间  5.说明")
        number = input("请输入要操作的功能序号[1-5]:")
        if number == "1":
            ids = int(input("请输入ID:"))
            style[ids-1] = input("请输入修改内容：")
            break
        elif number == "2":
            ids = int(input("请输入ID:"))
            account[ids-1] = input("请输入修改内容：")
            break
        elif number == "3":
            ids = int(input("请输入ID:"))
            money[ids-1] = input("请输入修改内容：")
            break
        elif number == "4":
            ids = int(input("请输入ID:"))
            time[ids-1] = input("请输入修改内容：")
            break
        elif number == "5":
            ids = int(input("请输入ID:"))
            instructions[ids-1] = input("请输入修改内容：")
            break
        else:
            print("输入错误，请重新输入！")
    print("编辑成功!")


def add_account():
    ID.append(len(ID)+1)
    style.append(input("请输入类别："))
    account.append(input("请输入账户："))
    money.append(input("请输入金额："))
    time.append(input("请输入时间："))
    instructions.append(input("请输入说明："))
    print("添加成功！")


def register():
    count = 0
    while count < 3:
        count += 1
        name = input('请输入登录账户名:')
        code = input('请输入登录账户密码:')
        x = 0
        if name == administrator[0]:
            x = 0
        if name == administrator[1]:
            x = 1
        if name == administrator[x] and code == password[x]:
            while True:
                print("1.添加账务  2.编辑账务  3.删除账务  4.查询账务  5.退出系统")
                number = input("请输入要操作的功能序号[1-5]:")
                if number == "1":
                    add_account()
                elif number == "2":
                    edit_account()
                elif number == "3":
                    del_account()
                elif number == "4":
                    check_account()
                elif number == "5":
                    exit_system()
                    break
                else:
                    print("输入错误，请重新输入")
            break
        else:
            print("您输入的账户名或密码有误请重新登录!")
    if count == 3:
        print("密码输入连续错误三次，结束登录!")


if __name__ == '__main__':
    register()
